package com.wavehi.util;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;

/**
 * @Author WaveHi
 * @Date 13/9/2021 下午 8:36
 * @Version 1.0
 * @Contact HJBWaveHi@163.com
 * @Description
 */
public class MyBatisUtils {
    private static SqlSessionFactory ssf;//连接器工厂
    static{
        //获取配置文件输入流
        InputStream in = ClassLoader.getSystemClassLoader().getResourceAsStream("mybatis-config.xml");
        //获取连接器工厂
        ssf = new SqlSessionFactoryBuilder().build(in);
    }

    public static SqlSession getConnection() {
        return ssf.openSession();
    }
}
